package il.ac.tau.cvws.scrabblesidekick.client.app;

import il.ac.tau.cvws.scrabblesidekick.client.engine.storage.DataKeyStorage;
import il.ac.tau.cvws.scrabblesidekick.client.util.communication.CommServices;
import il.ac.tau.cvws.scrabblesidekick.client.util.dictionary.Dictionary;
import il.ac.tau.cvws.scrabblesidekick.client.util.dictionary.hebrew.HebrewDictionary;

public class AppServices
{
	private static AppServices _instance;
	
	private final Dictionary         _dictionary;
	private final DataKeyStorage     _storage;
	private final CommServices   _comm;
	
	private AppServices()
	{
		_dictionary = new HebrewDictionary();
		_storage    = new DataKeyStorage();
		_comm 		= new CommServices();
	}
	
	public static AppServices instance()
	{
		if (_instance == null)
		{
			_instance = new AppServices();
		}
		
		return _instance;
	}
	
	/* The application's dictionary, used by the rack controller and when
	 * displaying the solution to the user.
	 */
	public Dictionary dictionary()
	{
		return _dictionary;
	}
	
	/* The application's storage engine. The storage engine is used to store
	 * and retrieve the key that's returned from the server once the device is
	 * calibrated.
	 */
	public DataKeyStorage storage()
	{
		return _storage;
	}
	
	/* Implementation of communication services. These are used to send requests
	 * to the server.
	 */
	public CommServices comm()
	{
		return _comm;
	}
}
